package com.share.cloudStorage.folders.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.share.cloudStorage.folders.dao.FoldersDao;
import com.share.cloudStorage.folders.model.Folders;
import com.share.cloudStorage.users.model.Users;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class FoldersServiceImpl extends ServiceImpl<FoldersDao, Folders> implements FoldersService {

    @Autowired
    private FoldersDao foldersDao;

    @Override
    public void save(Users user){
        Folders folders = new Folders();
        folders.setFolderName(user.getMobile());
        folders.setUserId(user.getUserId());
        folders.setCreateTime(user.getCreateTime());
        foldersDao.insert(folders);
    }

    //通过用户id获取文件夹名称
    public String getFolderNameById(Integer userId){
        QueryWrapper<Folders> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        Folders folders = foldersDao.selectOne(queryWrapper);
        log.info("folders：{}",folders);
        return folders.getFolderName();
    }
}

